<!DOCTYPE html>
<html lang="en">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>网络货运平台省运管数据控制台</title>
    <meta name="renderer" content="webkit">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="keywords" content="小镖人、社区、网络货运">
    <meta name="description" content="小镖人、社区、网络货运">
    <link rel="stylesheet" href="../../../xbr_layui_extend/layui-v2.6.8/css/layui.css">
</head>
<body>
<div class="layui-fluid" style="padding: 15px;">
    <!--表格部分-->
    <table class="layui-hide" id="accTable" lay-filter="accTable"></table>
    <div class="accTablePage"></div>
</div>

<!--隐藏模板 -->
<script type="text/html" id="bar">
    <a class="layui-btn layui-btn-sm" lay-event="reqXml">请求XML数据</a>
    <a class="layui-btn layui-btn-sm" lay-event="resXml">接收XML数据</a>
</script>

<script src="../../../xbr_layui_extend/layui-v2.6.8/layui.js"></script>
<script>
    layui.extend({
        admin: '/platform/xbr_layui_extend/admin' //集成路径
    }).use(["admin",'table','laypage'], function () {
        const $ = layui.$,admin=layui.admin, table = layui.table, laypage = layui.laypage;

        //加载TABLE
        refTable(1, 10);

        function refTable(page, limit) {
            admin.req({
                url: "/platform/pab/getDockingLogPage",
                data: {page: page, limit: limit},
                done: function (res) {
                    if (res.data == null) return;
                    table.render({
                        elem: '#accTable',
                        cols: [[ //标题栏
                            {title: '请求时间', minWidth: 100, templet: (d) => nullTxt(d["reqTime"])},
                            {title: '标题', minWidth: 150,  templet: (d) => nullTxt(d["title"])},
                            {title: '是否成功', templet: (d) => d["title"]?"成功":"失败"},
                            {fixed: 'right', title: 'XML', toolbar: '#bar', width: 300,align:"center"}
                        ]],
                        data: res.data.list
                    });
                    //总页数低于页码总数
                    laypage.render({
                        elem: 'accTablePage',
                        limit: limit,
                        limits: [10, 50, 100, 500],
                        count: res.data.total, //数据总数
                        jump: function (obj, first) {
                            if (first) return;
                            refTable(obj.curr, obj.limit)
                        }
                    });
                }
            });
        }

        //监听行工具事件
        table.on('tool(accTable)', function(obj){
            const data = obj.data;
            if (obj.event==='reqXml'){
                const xml = '<pre class="layui-code">'+ data['reqXml'] + '</pre>'
                layer.confirm(xml, {offset: 'auto'})
            }
            if (obj.event==='resXml'){
                const xml = '<pre class="layui-code">'+ data['resXml'] + '</pre>'
                layer.confirm(xml, {offset: 'auto'})
            }
            layui.code({encode:true});
        });
        function nullTxt(value) {
            if (value == null || value === "") return "无数据";
            return value;
        }
    });
</script>
</body>
</html>